home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 2.6 KB | 103 lines | [TEXT/MPS ] |
- (*
- CTBDisplay([leftCol,topRow,rightCol,bottomRow]) -- Return the current terminal emulator display.
- If the rows and columns parameters are present, only return that rectangle of the display.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBDisplay.p
- link -m ENTRYPOINT -o HyperCommands -rt XFCN=2756 -sn Main=CTBDisplay ∂
- CTBDisplay.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBDisplay } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBDisplay(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBDisplay(paramPtr);
- end;
-
- procedure CTBDisplay(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var i: integer;
- theEnvirons: TermEnvironRec;
- sel: TMSelection;
- h: Handle;
- p: Ptr;
- l: longInt;
- t: ResType;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBDisplay);
- end;
-
- begin
- { Check the parameter count. }
- i := paramPtr^.paramCount;
- if (i <> 0) and (i <> 4) then Fail('Invalid parameter count');
-
- { Check that the Comm Toolbox is available. }
- CTBReady;
- { And a terminal tool is also present. }
- EnsurePresent(terminalTool);
-
- { Get the screen rectangle to retrieve. }
- theEnvirons.version := curTermEnvRecVers;
- FailOSErr(TMGetTermEnvirons(Globals^^.termHand,theEnvirons));
- with sel.selRect do
- begin
- top := 1;
- left := 1;
- bottom := theEnvirons.textRows;
- right := theEnvirons.textCols;
- if ParmPresent(1) and ParmPresent(2) and ParmPresent(3) and ParmPresent(4) then
- begin
- l := GetLongParm(1); if l > 1 then left := l;
- l := GetLongParm(2); if l > 1 then top := l;
- l := GetLongParm(3); if l < right then right := l;
- l := GetLongParm(4); if l < bottom then bottom := l;
- end;
- end;
-
- { Do a set selection/get selection. }
- TMSetSelection(Globals^^.termHand,sel,selTextBoxed);
- h := NewHandle(0);
- if h = nil then Fail('Could not allocate handle');
- l := TMGetSelect(Globals^^.termHand,h,t);
- { If we got something, then return it as a regular HyperCard string. }
- if (l >= 0) and (t = 'TEXT') then
- begin
- l := GetHandleSize(h);
- SetHandleSize(h,l+1);
- p := Ptr(ord4(h^)+l);
- p^ := 0;
- paramPtr^.returnValue := h
- end
- { Otherwise forget it. }
- else DisposHandle(h);
- end;
-
- end.
-